package com.yunsc.system.utils;

import cn.hutool.crypto.symmetric.SymmetricAlgorithm;
import cn.hutool.crypto.symmetric.SymmetricCrypto;

/**
 * @version: 1.0
 * @Author: adan
 * @description: 加密工具类
 * @date: 2024-05-06 14:40
 */
public class EncryptUtil {

    private static final byte[] KEY = "1234567890123456".getBytes(); // 密钥长度为16个字节

    // 加密
    public static String yunscEncrypt(String value) {
        SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, KEY);
        return aes.encryptBase64(value);
    }

    // 解密
    public static String yunscDecrypt(String encrypted) {
        SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, KEY);
        return aes.decryptStr(encrypted);
    }
}
